package cn.yibao.interviewtest.service.impl;

import cn.yibao.interviewtest.mapper.UserMapper;
import cn.yibao.interviewtest.pojo.User;
import cn.yibao.interviewtest.service.UserService;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@CacheConfig(cacheNames = "interview")
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;
    @Override
    public List<User> getUsers(User user) {
        return userMapper.getUsers(user);
    }

    @Cacheable(value = "user",key = "#user.id")
    @Override
    public int saveUser(User user) {
        return userMapper.saveUser(user);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }
}
